'''
Created on Jul 9, 2011

@author: kafkef
'''

from PyQt4.QtGui import *

from dexen.system.client import ui

from dexen.system.client.ui.pages.inds_page import IndsPage
from dexen.system.client.ui.pages.execution_log_page import ExecutionLogPage
from dexen.system.client.ui.pages.summary_page import SummaryPage


svr_proxy = ui.svr_proxy


class JobTabWidget(QTabWidget):
    def __init__(self):
        QTabWidget.__init__(self)
        self._cur_focused_job = None
        self._create_pages()
        self._add_tabs()
        
    def _create_pages(self):
        self.summaryPage = SummaryPage()
        self._job_log_page = ExecutionLogPage()
        self.indsPage = IndsPage()
        
    def _add_tabs(self):
        self.addTab(self.summaryPage, "Summary")
        self.addTab(self._job_log_page, "Execution Log")
        self.addTab(self.indsPage, "Individuals")
    
    def on_cur_job_changed(self, job_info):
        print "JobTabWidget:on_cur_job_changed"
        self.summaryPage.on_cur_job_changed(job_info)
        self._job_log_page.on_cur_job_changed(job_info)        
        self.indsPage.on_cur_job_changed(job_info)
    
    def on_actions_received(self, job_info, actions):
        self._job_log_page.on_actions_received(job_info, actions)
    
    def on_actions_initialized(self, job_info, actions):
        self._job_log_page.on_actions_initialized(job_info, actions)
    
    def on_server_info_updated(self, svr_info):
        self.summaryPage.on_server_info_updated(svr_info)
    
    def on_server_info_initialized(self, svr_info_list):
        self.summaryPage.on_server_info_initialized(svr_info_list)
    
    def on_inds_initialized(self, job_info, inds):
        self.indsPage.on_inds_initialized(job_info, inds)
    
    def on_inds_updated(self, job_info, inds):
        self.indsPage.on_inds_updated(job_info, inds)

